Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git] / 11428 - Cubes / b.cpp
blobea5ed4673c570ebc58f45cfb97ae17e278bca9ea
1 #include<iostream>
2 #include<math.h>
3 using namespace std;
4 int main(){
5 int n;
6 while(cin>>n &&n){
7 double aux=(1.+sqrt(1.+(8.*sqrt((double)(n)))))/2;
8 aux=floor(aux);
10 if(n==(aux*aux*aux-(aux-1)*(aux-1)*(aux-1))){
11 cout<<aux<<" "<<aux-1;
12 }else{
13 int i=1;
14 while(i*i*i <= (n+1)){
15 ++i;
17 --i;
18 // cout << i << endl;
19 if (i*i*i == n+1){
20 cout << i << " 1";
21 } else{
22 cout<<"No solution";
25 cout<<endl;